#pragma once

#include "RealObject/Store.h"
#include "RealObject/GroupProduct.h"
#include "RealObject/ListProduct.h"
#include "RealObject/Provider.h"
#include "GridCtrl/GridCtrl.h"
#include "maskededit/OXMaskedEdit.h"
// CCommonView form view

class CCommonView : public CView
{
	DECLARE_DYNCREATE(CCommonView)

public:
	CCommonView();           // protected constructor used by dynamic creation
	virtual ~CCommonView();

public:
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
#ifdef _DEBUG
	virtual void AssertValid() const;
#ifndef _WIN32_WCE
	virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
	afx_msg void OnGridRClick(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnClick(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnEndEditTranfer(NMHDR *pNMHDR, LRESULT *pResult);	
	afx_msg void OnGridStartSelChange(NMHDR *pNotifyStruct, LRESULT* pResult);
	afx_msg void OnDropbutton(NMHDR *pNotifyStruct, LRESULT* pResult);

	afx_msg void OnEditStaff(NMHDR *pNotifyStruct, LRESULT* pResult);
	afx_msg void OneditGroup(NMHDR *pNotifyStruct, LRESULT* pResult);

	afx_msg void OnGridRClickInput(NMHDR *pNMHDR, LRESULT *pResult);	
	afx_msg void OnEndEditNumber(NMHDR *pNMHDR, LRESULT *pResult);

	afx_msg void OnEditStore(NMHDR *pNMHDR, LRESULT *pResult);
	 
	
	DECLARE_MESSAGE_MAP()
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);

	void OnBnClickedUpdateDB();
	void  OnExportInputExcel();
	void onAddStore();
	void onDelete();
	void onEdit();
	void onReload();
	void onViewReport();
	void onExportToExcel();
	void OnViewCheck();
	void OnExportCheck();
	void OnTransfer();

	void OnAddStaff();
	void OnAddProvider();
	void OnInsertProviderToGrid(CProvider* pProvider);

	void OnReloadSetting();
	void OnUpdateSetting();
public:
	void initStore();
	
	void InitInputStore();
	void initGridToReport(int nTypeReport);
	void initGridToTranfer();
	void OnInsertRowTransfer();
	void addStoreToList(const CStore* pStore);
	void addGroupToList(const CGroupProduct* pGroup);

	void ReloadGridGroup();
	void ReloadGridStore();
	void addProductToList(const CListProduct* pList);

	void addStaffToGridStaff( CStaff* pStaff);
	void reloadListCheckPoint();
	void OnUpdateCheckPoint();


	int getNumPhoneInGrid(int& nLastMB, int& nLastAcc);
	int getMaxCodePhoneInGrid();
	afx_msg void onInsertRow();
public:
	CGridCtrl m_GridCInputView;
	CGridCtrl m_GridStoreView;
	CGridCtrl m_GridReport;
	CGridCtrl m_gridTranfer;
	CGridCtrl m_gridCheckStore;
	CGridCtrl m_gridStaff;
	CGridCtrl m_gridProvider;
	CGridCtrl m_gridCheckPoint;
	CGridCtrl m_gridSalary;
	int m_nView;

	CDateTimeCtrl* pDataTimeStart;
	CDateTimeCtrl* pDataTimeEnd;
	CComboBox* pComboReport;
	CComboBox* pComboStore;
	CComboBox* pCombStoreAtCheck;
	CComboBox* pComboTranfer;
	CEdit* pEditCodeTrans;	

	COXMaskedEdit* pStaffReceive;

	CEdit* pEditCode;
};


